package com.ha.mapper;

import com.github.pagehelper.Page;
import com.ha.annotation.AutoFillU;
import com.ha.dto.BannerPageDTO;
import com.ha.entity.Banner;
import com.ha.enumeration.OperationType;
import com.ha.vo.BannerVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName: BannerMapper
 * Package: com.ha.mapper
 * Description:
 *
 * @Author 那啥啥
 * @Create 2024/5/2  19:24
 * @Version 1.0
 */
@Mapper
public interface BannerMapper {
    @Insert("insert into banner (img, create_time, update_time, deleted,title) VALUES " +
            "(#{img},#{createTime},#{updateTime},#{deleted},#{title})")
    @AutoFillU(OperationType.INSERT)
    public void addBanner(Banner banner) ;

    Page<Banner> pageQuery(BannerPageDTO bannerDTO);

    @Select("select *from banner where id = #{id}")
    Banner getById(Long id);

    @Update("update banner set deleted = #{deleted} where id = #{id}")
    @AutoFillU(OperationType.UPDATE)
    void deleteById(Long id, Integer deleted);

    @AutoFillU(OperationType.UPDATE)
    void update(Banner banner);

    @Select("select  *from banner limit 0,4")
    List<BannerVO> getBanner();
}
